<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<html>

<head>
    
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="robots" content="all,follow">

    <title>Shop Manager</title>
    <link rel="shortcut icon" href="img/favicon.ico" th:href="@{/model1/img/favicon.ico}">

    <!-- global stylesheets -->
    <link href="https://fonts.googleapis.com/css?family=Roboto+Condensed" rel="stylesheet">
    <link rel="stylesheet" href="css/bootstrap.min.css" th:href="@{/model1/css/bootstrap.min.css}">
    <link rel="stylesheet" href="font-awesome-4.7.0/css/font-awesome.min.css" th:href="@{/model1/font-awesome-4.7.0/css/font-awesome.min.css}">
    <link rel="stylesheet" href="css/font-icon-style.css" th:href="@{/model1/css/font-icon-style.css}">
    <link rel="stylesheet" href="css/style.default.css" th:href="@{/model1/css/style.default.css}" id="theme-stylesheet">

    <!-- Core stylesheets -->
    <link rel="stylesheet" href="css/form.css"  th:href="@{/model1/css/form.css}">
</head>

<body> 

<!--====================================================
                         MAIN NAVBAR
======================================================-->
    <header th:replace="model1/common/bar::topbar"></header>

<!--====================================================
                        PAGE CONTENT
======================================================-->
    <div class="page-content d-flex align-items-stretch">

        <!--***** SIDE NAVBAR *****-->
        <nav th:replace="model1/common/bar::sidebar(activeUri='product_mng')"></nav>

        <div class="content-inner chart-cont">

            <!--***** CONTENT *****-->     
            <div class="row">

                <!--***** FORM INPUTS *****-->
                <div class="col-md-12">
                    <form id="form1" name="form1" th:action="@{/admin/product/update.do}" th:method="post" enctype="multipart/form-data">
                    <div class="card form">
                    <div class="card-header">
                        <h3>修改商品</h3>
                    </div>
                    <br>
                    <div class="row">
                        <div class="col-md-6" style="margin-left: auto;margin-right: auto">
                            <div class="form-group row" >
                                <label for="sock_id" style="width: 85px;" class=" col-form-label">商品编号</label>
                                <div class="col-9">
                                    <input class="form-control" type="text"  id="sock_id" name="sock_id" th:value="${product.sock_id}" readonly>
                                    <div style="color: #FF0000" id="pid_tip"></div>
                                </div>
                            </div>
                            <div class="form-group row">
                                <label for="name" style="width: 85px;" class=" col-form-label">商品名称</label>
                                <div class="col-9">
                                    <input class="form-control" type="text"  id="name" name="name" th:value="${product.name}">
                                    <div style="color: #FF0000" id="pname_tip"></div>
                                </div>
                            </div>

                            <div class="form-group row">
                                <label for="price" style="width: 85px;" class=" col-form-label">商品价格</label>
                                <div class="col-9">
                                    <input class="form-control" type="text"  id="price" name="price" th:value="${product.price}">
                                    <div style="color: #FF0000" id="price_tip"></div>
                                </div>
                            </div>
                            <div class="form-group row">
                                <label for="count" style="width: 85px;" class=" col-form-label">库存数量</label>
                                <div class="col-9">
                                    <input class="form-control" type="text"  id="count" name="count" th:value="${product.count}">
                                    <div style="color: #FF0000" id="count_tip"></div>
                                </div>
                            </div>
                            <div class="form-group row">
                                <label for="description" style="width: 85px;" class=" col-form-label">商品描述</label>
                                <div class="col-9">
                                    <textarea rows="3" cols="30"  th:text="${product.description}" class="form-control" id="description" name="description"></textarea>
                                </div>
                            </div>
                            <div class="form-group row">
                                <label for="description" style="width: 85px;" class=" col-form-label">分类标签</label>
                                <div class="col-9" id="tags">
                                    <table>
                                        <tbody >
                                            <tr th:each="tagVo,index:${tagList}">
                                                <td th:text="${tagVo.name}"></td>
                                                <!--<td >-->
                                                    <!--<a  href="javascript:void(0);" th:onclick="'javascript:deleteTag('+${tagVo.tag_id}+');'" id="delete" class="btn btn-sm btn-danger">删除</a>-->
                                                <!--</td>-->
                                                <td >
                                                    <a  th:href="'javascript:deleteThisTag('+${tagVo.tag_id}+');'">删除</a>
                                                </td>
                                            </tr>
                                        </tbody>
                                    </table>
                                    <a href="#myModal" data-toggle="modal" title="Compose" class="btn btn-success"> 添加新分类 </a>
                                    <!-- Modal -->
                                    <div aria-hidden="true" aria-labelledby="myModalLabel" role="dialog" tabindex="-1" id="myModal" class="modal fade" style="display: none;">
                                        <div class="modal-dialog">
                                            <div class="modal-content">
                                                <div class="modal-header">
                                                    <h4 class="modal-title">添加新分类</h4>
                                                    <button aria-hidden="true" data-dismiss="modal" class="close" type="button">×</button>
                                                </div>
                                                <div class="modal-body">
                                                    <form role="form" class="form-horizontal" th:action="@{/admin/product/update/addTag.do}" th:method="post">
                                                        <div class="row form-group">
                                                            <label class="col-lg-3 control-label">分类选择</label>
                                                            <div class="col-lg-9">
                                                                <select class="form-control" id="categoryid"  name="categoryid">
                                                                    <!--<option selected  readonly th:text="${product.category.cname}" th:value="${product.category.cid}"></option>-->
                                                                    <option  th:value="${tag.tag_id}" th:each="tag:${noTagList}" th:text="${tag.name}"></option>
                                                                </select>
                                                            </div>
                                                        </div>
                                                        <!--<div class="row form-group">-->
                                                        <!--<label for="num" class="col-lg-3 control-label">分类编号</label>-->
                                                        <!--<div class="col-lg-9">-->
                                                        <!--<input type="text" placeholder="" id="num" class="form-control">-->
                                                        <!--<div style="color: #FF0000" id="num_tip">-->
                                                        <!--</div>-->
                                                        <!--</div>-->
                                                        <!--</div>-->

                                                        <div class="row form-group">
                                                            <div class="offset-lg-2 col-lg-10">
                                                                <a  href="javascript:void(0);" th:onclick="'javascript:submit();'" id="submit" class="btn btn-sm btn-success">提交</a>
                                                            </div>
                                                        </div>
                                                    </form>
                                                </div>
                                            </div>
                                            <!-- /.modal-content -->
                                        </div>
                                        <!-- /.modal-dialog -->
                                    </div>
                                    <!-- /.modal -->                                </div>

                            </div>

                            <div class="form-group row">
                                <label for="image_1" style="width: 85px;" class=" col-form-label">商品图片1</label>
                                <div class="col-9">
                                    <img width="100" height="100" th:if="${product.image_url_1!=null}" th:src="@{/}+${product.image_url_1}">
                                    <input hidden readonly  id="pimage_pic1_text" name="pimage_pic1_text"  th:value="${product.image_url_1}" />
                                    <input type="file" class="form-control-file" id="image_1" name="image_1">
                                    <div style="color: #FF0000" id="pimage_pic_tip"></div>
                                </div>
                            </div>

                            <div class="form-group row">
                                <label for="image_2" style="width: 85px;" class=" col-form-label">商品图片2</label>
                                <div class="col-9">
                                    <img width="100" height="100" th:if="${product.image_url_2!=null}" th:src="@{/}+${product.image_url_2}">
                                    <input hidden readonly id="pimage_pic2_text" name="pimage_pic2_text"  th:value="${product.image_url_2}" />
                                    <input type="file" class="form-control-file" id="image_2" name="image_2">
                                    <div style="color: #FF0000" id="pimage_pic2_tip"></div>
                                </div>
                            </div>

                            <div class="form-group row" >
                                <div class="col-9">
                                        <button type="button" class="btn btn-success" onclick="validateAndSubmit()">更新信息</button>
                                        <button type="button" class="btn btn-danger" onclick="deleteProduct()">删除商品</button>
                                </div>
                            </div>

                        </div>
                    </div>
                </div>
                    </form>
                </div>
            </div> 

        </div>
    </div>

    <!--Global Javascript -->
    <script src="js/jquery.min.js" th:src="@{/model1/js/jquery.min.js}"></script>
    <script src="js/popper/popper.min.js" th:src="@{/model1/js/popper/popper.min.js}"></script>
    <script src="js/tether.min.js" th:src="@{/model1/js/tether.min.js}"></script>
    <script src="js/bootstrap.min.js" th:src="@{/model1/js/bootstrap.min.js}"></script>
    <script src="js/jquery.cookie.js" th:src="@{/model1/js/jquery.cookie.js}"></script>
    <script src="js/jquery.validate.min.js" th:src="@{/model1/js/jquery.validate.min.js}"></script>
    <script src="js/chart.min.js" th:src="@{/model1/js/chart.min.js}"></script>
    <script src="js/front.js" th:src="@{/model1/js/front.js}"></script>

    <!--Core Javascript -->
    <!--<script src="js/mychart.js" th:src="@{/model1/js/mychart.js}"></script>-->
    <script src="" th:src="@{/model1/js/product/product_chg.js}"></script>
    <script src="" th:src="@{/model1/js/common.js}"></script>

</body>

</html>